package pCloud.stream;

import java.util.Vector;

/*
 * The Map Box class
 * It has a list of attributes which is a subset of the attributes of input stream.
 * The other attributes are not included in the output stream
 * 
 */
public class MapBox {
	public Vector<String> attributes; // projected attributes from original stream schema
	public String mergeMsg;
	
	public MapBox(){
		
		this.attributes = new Vector<String>();
		this.mergeMsg = "";
	}
	
	public void print() {		
		System.out.println("Attributes in MapBox");
		for (int i=0; i<this.attributes.size();i++)
			System.out.println(this.attributes.elementAt(i));
	}
	
	/*
	public String toXAML() {
		
		String xacml = "";
		
		xacml += "<Condition FunctionId=\"" + PCloudAttributeAndType.SUBSET_STRING + "\">" + Global.eol;
		xacml += "<ResourceAttributeDesignator AttributeId=\"" + PCloudAttributeAndType.RESOURCE_STREAM_ATTRIBUTE_ID + "\" DataType = \"" + PCloudAttributeAndType.TYPE_STRING + "\"/>" + Global.eol;
		
		xacml += "<Apply FunctionId=\"" +PCloudAttributeAndType.BAG_STRING + "\">" + Global.eol;
		for (int i=0; i< this.attributes.size(); i++){
			
			xacml += "<AttributeValue DataType=\"" + PCloudAttributeAndType.TYPE_STRING + "\">";
			xacml += this.attributes.elementAt(i);
			xacml += "</AttributeValue>" + Global.eol;
		}		
		xacml += "</Apply>" +Global.eol;
		xacml += "</Condition>" + Global.eol;
		return xacml;
	}
	*/
	
	public String createSSQL(String input,String output){
		
		String ssql="";
		ssql += "SELECT " + Global.eol;
		for (int i=0; i<this.attributes.size()-1; i++){
			
			ssql += input + "." + this.attributes.elementAt(i)+"," + Global.eol;
		}
		ssql += input + "." + this.attributes.elementAt(this.attributes.size()-1) + Global.eol;
		ssql += "FROM " + input + " INTO " + output ;
		
		ssql += ";" + Global.eol;
		return ssql;
	}
}
